#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
int main(){
	int n,m;
	cin >> n >> m;
	int max = -1;
	int temp,flag = 0;
	for(int i = 0;i < n;i++){
		int rmax = -1;
		for(int j = 0;j < m;j++){
			cin >> temp;
			if(temp>rmax) rmax = temp;
			if(temp>max) max = temp;
		}
		if(flag) cout << " ";
		cout << rmax;flag = 1;
	}
	printf("\n%d",max);
	return 0;
}
